summaryrefslogtreecommitdiff
path: root/src/pages/[locale]/news
diff options
context:
space:
mode:
authorJoe Carstairs <jcarstairs@scottlogic.com>2023-08-15 19:15:27 +0100
committerJoe Carstairs <jcarstairs@scottlogic.com>2023-08-15 19:15:27 +0100
commit53f29bac911b13b2bef0125de22773bf26ce5a90 (patch)
treee4dad6d88e2fe4c4eda8ff286db50d9a6f561242 /src/pages/[locale]/news
parent8b009f0ea6ea9d181ba8d0e6549c25645aa697c4 (diff)
Adds homepage
Diffstat (limited to 'src/pages/[locale]/news')
-rw-r--r--src/pages/[locale]/news/index.astro9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/pages/[locale]/news/index.astro b/src/pages/[locale]/news/index.astro
index 0c81fd9..c64fbdb 100644
--- a/src/pages/[locale]/news/index.astro
+++ b/src/pages/[locale]/news/index.astro
@@ -6,18 +6,13 @@ import getLocaleFromPath from '$lib/getLocaleFromPath';
import localeStaticPaths from '$lib/localeStaticPaths';
import { getCollection } from 'astro:content';
import NewsPreviewLink from '$components/NewsPreviewLink.astro';
+import { isNewsItemInLocale } from '$lib/newsUtils';
const allNews = await getCollection('news');
const locale = getLocaleFromPath(Astro.url.pathname);
-const allNewsInLocale = allNews.filter(isInLocale);
+const allNewsInLocale = allNews.filter((item) => isNewsItemInLocale(item, locale));
const t = translate(locale);
-function isInLocale(newsItem: (typeof allNews)[number]) {
- const srcPath = newsItem.id;
- const newsItemLocale = srcPath.slice(0, srcPath.indexOf('/'));
- return newsItemLocale === locale;
-}
-
export async function getStaticPaths() {
return localeStaticPaths;
}